<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMiniProgramOperationRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mini_program_operation_records', function (Blueprint $table) {
            $table->increments('id')->comment('表备注：项目小程序操作记录');
            $table->integer('user_id')->default(0)->comment('操作用户id');
            $table->integer('ap_id')->default(0)->comment('小程序/公众号项目表表id');
            $table->string('open_appid',190)->nullable()->default('')->comment('开放平台appid');
            $table->string('wx_authorizer_appid',190)->nullable()->default('')->comment('授权方 appid');
            $table->string('op_name')->comment('操作名称');
    
            $table->string('wx_auditid')->default('')->comment('微信小程序最后提交审核审核编号');
            $table->tinyInteger('op_result')->default(0)->comment('操作结果：0: 无结果记录，1：成功，2：失败');
            $table->text('result')->comment('结果记录');
    
            $table->dateTime('created_at')->nullable()->default(null);
            $table->dateTime('updated_at')->nullable()->default(null);
            $table->tinyInteger('deleted')->default(0)->comment('是否删除,1:是,0:否');
    
            $table->index(['user_id']);
            $table->index(['ap_id']);
            $table->index(['open_appid']);
            $table->index(['wx_authorizer_appid']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mini_program_operation_records');
    }
}
